import type { AdminInfo } from '~/utils/mock-data';

import { faker } from '@faker-js/faker';
import { MOCK_ADMINS } from '~/utils/mock-data';

export default defineEventHandler(async (event) => {
  const { password, username, realName, roles } = await readBody(event);
  const user: AdminInfo = {
    id: faker.string.uuid(),
    username,
    realName,
    password,
    roles,
  };
  MOCK_ADMINS.push(user);
  return useResponseSuccess(null);
});
